<template>
    <div>
      <table>
        <tr>
          <td>编号</td>
          <td>图书名称</td>
          <td>作者</td>
        </tr>
        <tr v-for="item in books" :key="item.id">
          <td>{{item.id}}</td>
          <td>{{item.name}}</td>
          <td>{{item.author}}</td>
        </tr>
      </table>
      {{msg}}
    </div>
</template>

<script>
import axios from 'axios'
export default {
  name: 'Book',
  data () {
    return {
      msg: 'hello Vue',
      books: [
        {
          id: 1,
          name: 'java基础',
          author: '作者1'
        },
        {
          id: 2,
          name: 'java进阶',
          author: '作者2'
        },
        {
          id: 3,
          name: 'javaEE',
          author: '作者3'
        }
      ]
    }
  },
  created () {
    const _this = this
    axios.get('http://localhost:8181/book/findAll').then(function (resp) {
      console.log(resp)
      _this.books = resp.data
    })
  }
}
</script>

<style scoped>

</style>
